<?php
class Form_Customer extends Zend_Form
{
    public function __construct($options=array())
    {
		parent::__construct($options);
		$this->setMethod('post');
		$this->addPrefixPath('Lion_Form_Element', '../library/Form/Element/', 'element');
		
		Zend_Loader::loadClass('Common', array('../application/default/models/'));
		$this->setMethod('post');
		$mod_common = new Common();
		$city_arr = $mod_common->getCities();
		
		$this->addPrefixPath('Lion_Form_Element', '../library/Form/Element/', 'element');
			
	   
	    $this->addElement('text', 'customer_name', array(
            'label'      => 'Customer Name:',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'class'		 => 'inp-form',
            'onblur'	 => 'genCustCode()',
            'validators' => array(
            	array('validator' => 'StringLength', 'options' => array(0, 100))
            )
        ));
		
		$this->addElement('text', 'customer_code', array(
            'label'      => 'Customer Code:',
            'readonly'	 => 'readonly',            
            'filters'    => array('StringTrim'),
            'class'		 => 'inp-form',
            'validators' => array(
            	array('validator' => 'StringLength', 'options' => array(0, 100))
            )
        ));	
        	
		
		$customer_logo = new Zend_Form_Element_File('fileToUpload');
        $customer_logo->setLabel('Customer Logo')
                 ->setRequired(true)
                 ->addValidator('NotEmpty')
                 ->setAttrib('class' ,'inp-form')
                 ->setAttrib('size', '43');
                 //->addDecorator(array('endbit'=>'HtmlTag'), array('tag' => 'div', 'class' => 'showimage', 'placement' => 'append'));				 
        $this->addElement($customer_logo);

        
        $status = new Zend_Form_Element_Select('status');
        $status ->setLabel('Status')
		 			 ->addMultiOptions(array(
						'' => 'Select Status',
		 			    1 => 'Active',
						0 => 'Inactive'));
						
		$this->addElement($status);
		
		$project_type = new Zend_Form_Element_Select('project_type');
        $project_type ->setLabel('Project Type')
		 			 ->addMultiOptions(array(
		 			    '' => 'Select Project Type',            
						'sap' => 'SAP',
						'accpac' => 'Accpac',
						'sap_development' => 'SAP + Development',
						'accpac_development' => 'Accpac + Development',
						'sap_support' => 'SAP Support Service',
						'accpac_support' => 'Accpac Support Service',
						'devlopment' => 'Development'));
		
		$this->addElement($project_type);
		
		/*$this->addElement('text', 'location', array(
            'label'      => 'Location:',            
            'filters'    => array('StringTrim'),
            'class'		 => 'inp-form',
            'validators' => array(
            	array('validator' => 'StringLength', 'options' => array(0, 100))
            )
        ));*/	
		
		$location = new Zend_Form_Element_Select('location');
		$location ->setLabel('Location');
		$location->setOptions(array('class'=>'input-2'));
		
		$location->addMultiOption('', 'Select City'); 		  
        foreach ($city_arr as $city_entry)
		{
			$location->addMultiOption($city_entry['city_id'], $city_entry['city_name']);
		}
		
		$this->addElement($location);
		
		if(!empty($options))
		{
    		if($options['action'] == "edit")
    		{ 
        	   	$this->addElement('hidden', 'customer_id', array(	            
        	            'filters'  => array('int'),
        	            'class'	   => 'hidden',
        	            'value'    => $options['customer_id'],	            
        	    ));
    		}
		}	
		
		//$this->setDecorators( array( array('ViewScript', array('script' => 'index.phtml'))));  
    }
}
